package com.lv.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lv.entity.Customer;
import com.lv.mapper.CustomerMapper;
import com.lv.service.CustomerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 凉薄
 * @since 2022-01-21
 */
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
    /**
     * 获取客户列表&&根据条件查询客户
     * @param current 当前页码
     * @param size 单页记录数
     * @param customer 查询条件
     * @return
     */
    @Override
    public IPage<Customer> getCustomerList(Integer current, Integer size, Customer customer) {
        IPage<Customer> iPage=new Page<>(current,size);
        LambdaQueryWrapper<Customer> wrapper=new LambdaQueryWrapper<>();
        wrapper.like(Strings.isNotEmpty(customer.getCustName()),Customer::getCustName,customer.getCustName());
        wrapper.like(Strings.isNotEmpty(customer.getPhone()),Customer::getPhone,customer.getPhone());
        return page(iPage,wrapper);
    }
}
